$def with (profile, sections, model)

<script type="text/javascript">
$$(document).ready(function() {
    $$( "#tabs" ).tabs({
        beforeLoad: function( event, ui ) {
            ui.jqXHR.error(function() {
                ui.panel.html("Ai.. Something when wrong in the compilation. Check the log!")
            });
        }
    });


    $$("#run").click(function() {
        console.log($$("#run").text())
        $$.post( "/run", { 
            'id': $profile.id,
            'func': ($$("#run").text() == "Run") ? "start" : "stop"
        }).done(function( data ) {
            if(data.running){
                $$("#run").html('<span class="ui-button-text">Stop</span>');
            }
            else{
                $$("#run").html('<span class="ui-button-text">Run</span>');
            }
        });
    });

    $$( "#edit, #run" ).button()
});
</script>

<h1>$profile.title</h1>
<a id="run">Run</a>
<a id="edit" href="/edit/$profile.id">Edit</a>
<span id="status">Status: Stopped</span>
<div id="tabs">
    <ul>
    <li><a href="#tabs-1">Visual</a></li>
    <li><a href="/ajax/get_gcodes/$profile.id">Raw G-codes</a></li>
    </ul>
    <div id="tabs-1">
        <div id="sections">
            $for section in model.get_sections_by_profile_id(profile.id):
            <h3>$section.title</h3>        
            <ol class="sortable section" id="section-$section.id" section-id="$section.id">
                $for block in model.get_blocks_by_section_id(section.id):   
                <li id="block-$block.id" block-id="$block.id" index="$block.idx" settings="$block.settings">
                    <span class="block-$block.name">$block.name</span>
                    $for key,value in model.get_settings_by_block(block).iteritems():
                    <label>$key</label>
                    <label>$value</label>
                </li>
            </ol>
        </div>
    </div>
</div>



